import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;


public class JavaLoggingDemo {
  private final static Logger logger = Logger.getLogger(JavaLoggingDemo.class.getName());
  
  public static void main(String[] args) {
    logger.setLevel(Level.INFO);
    ConsoleHandler consoleHandler = new ConsoleHandler();
    SimpleFormatter formatter = new SimpleFormatter();
    consoleHandler.setFormatter(formatter);
    logger.addHandler(consoleHandler);
    
    JavaLoggingDemo jld = new JavaLoggingDemo();
    jld.writeLog();
  }
  
  public JavaLoggingDemo(){
    
  }
  
  public void writeLog() {
    // Set the LogLevel to Severe, only severe Messages will be written
    logger.setLevel(Level.SEVERE);
    logger.severe("Info Log");
    logger.warning("Info Log");
    logger.info("Info Log");
    logger.finest("Really not important");

    // Set the LogLevel to Info, severe, warning and info will be written
    // Finest is still not written
    logger.setLevel(Level.INFO);
    logger.severe("Info Log");
    logger.warning("Info Log");
    logger.info("Info Log");
    logger.finest("Really not important");
  }  
}
